<template>
  <div class="Practical-Training-list">
    <div
      class="Practical-Training-list-item display-common-horizontal-left"
      v-for="(item, index) in list"
      :key="index"
    >
      <div class="Practical-Training-list-item-img">
        <img src="../../assets/images/activeImg.png" alt="" />
      </div>
      <div
        class="Practical-Training-list-item-text display-common-vertical-left"
      >
        <div class="Practical-Training-list-item-text-title">
          <el-tooltip :content="item.title" placement="top">
            {{ item.title }}
          </el-tooltip>
        </div>
        <div class="Practical-Training-list-item-text-synopsis">
          简介:{{ item.synopsis }}
        </div>
        <div class="divider"></div>
        <div class="display-common-horizontal-between">
          <!-- 时间 状态 人数 评论 -->
          <div class="display-common-horizontal-left display-common-info">
            <div class="Practical-Training-list-item-text-time">
              <el-icon><Timer /></el-icon>
              <span class="span-margin">时间:</span>
              {{ item.time }}
            </div>
            <div class="Practical-Training-list-item-text-status">
              <el-icon><Operation /></el-icon>
              <span class="span-margin">状态:</span>
              {{ item.status }}
            </div>
            <div class="Practical-Training-list-item-text-number">
              <el-icon><User /></el-icon>
              <span class="span-margin">人数:</span>
              {{ item.number }}
            </div>
            <div class="Practical-Training-list-item-text-comment">
              <el-icon><ChatDotSquare /></el-icon>
              <span class="span-margin">评论:</span>
              {{ item.comment }}
            </div>
          </div>
          <div class="join-active" @click="joinActive(item.id)">
            <span class="button-common-gradient">加入活动</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import {
  Search,
  Timer,
  Operation,
  User,
  ChatDotSquare,
} from "@element-plus/icons-vue";
import { useRouter } from "vue-router";
const router = useRouter();
// 接受父组件数据
const props = defineProps({
  list: {
    type: Array,
    default: () => [],
  },
});
const joinActive = (id) => {
  console.log(id);
  // 跳转到活动详情页 nmae: "activityDetail", params: { id: id }
  router.push({
    name: "activityDetail",
    params: { id: id },
  })
  ElMessage({
    message: "加入活动成功",
    type: "success",
    plain: true,
  });
};
</script>

<style lang="scss" scoped>
.Practical-Training-list {
  margin-bottom: 20px;
  box-sizing: border-box;
  .Practical-Training-list-item {
    background: #ffffff;
    border-radius: 0px 0px 0px 0px;
    padding: 20px 22px;
    box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.3);
    border-radius: 10px 10px 10px 10px;
    margin-bottom: 30px;
    margin-top: 34px;
    width: 1196px;
    margin-left: 2px;
    margin-right: 1px;
    .Practical-Training-list-item-img {
      width: 266px;
      height: 120px;
      border-radius: 5px;
      img {
        height: 100%;
        width: 100%;
      }
    }
    .Practical-Training-list-item-text {
      margin-left: 20px;
      display: flex;
      flex: 1;
      .Practical-Training-list-item-text-title {
        margin-bottom: 20px;
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: bold;
        font-size: 22px;
        color: #4d84fa;
        text-align: left;
        font-style: normal;
        text-transform: none;
        cursor: pointer;
        // 溢出省略
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
        width: 600px;
      }
      .Practical-Training-list-item-text-synopsis {
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
        font-size: 14px;
        color: #707070;
        text-align: left;
        font-style: normal;
        text-transform: none;
        // calc(100% - 266px - 20px-22px);
        width: 892px; /* 定义容器宽度 */
        white-space: nowrap; /* 文本不换行 */
        overflow: hidden; /* 超出容器部分隐藏 */
        text-overflow: ellipsis; /* 使用省略号表示文本溢出 */
      }
      .divider {
        border: 1px solid #dedede;
        width: 100%;
        margin: 14px 0;
      }
      .span-margin {
        display: inline-block;
        margin: 0px 2px;
      }
      .Practical-Training-list-item-text-time {
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
        font-size: 14px;
        color: #707070;
        text-align: left;
        font-style: normal;
        text-transform: none;
        margin-right: 30px;
        display: flex;
        align-items: center;
      }
      .Practical-Training-list-item-text-status {
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
        font-size: 14px;
        color: #707070;
        text-align: left;
        font-style: normal;
        text-transform: none;
        margin-right: 30px;
        display: flex;
        align-items: center;
      }
      .Practical-Training-list-item-text-number {
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
        font-size: 14px;
        color: #707070;
        text-align: left;
        font-style: normal;
        text-transform: none;
        margin-right: 30px;
        display: flex;
        align-items: center;
      }
      .Practical-Training-list-item-text-comment {
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
        font-size: 14px;
        color: #707070;
        text-align: left;
        font-style: normal;
        text-transform: none;
        margin-right: 30px;
        display: flex;
        align-items: center;
      }
      .join-active {
        display: flex;
        align-items: center;
        justify-content: flex-end;
      }
    }
  }
}
</style>
